import { request } from "@/utils/service"
import type * as Agent from "./types/agent"
import { AxiosResponse } from "axios"

/** 增 */
export function createAgentDataApi(data: FormData) {
  return request({
    headers: {
      "Content-Type": "multipart/form-data"
    },
    url: "/toksim/resource/agent/add",
    method: "post",
    data
  })
}

/** 删 */
export function deleteAgentDataApi(id: string) {
  return request({
    url: `/toksim/resource/agent/delete/${id}`,
    method: "post"
  })
}

/** 改 */
export function updateAgentDataApi(data: FormData) {
  return request({
    headers: {
      "Content-Type": "multipart/form-data"
    },
    url: "/toksim/resource/agent/edit",
    method: "post",
    data
  })
}

/** 查 */
export function getAgentDataApi(params: Agent.PageTableRequestData) {
  return request<Agent.SearchAgentTableResponseData>({
    url: "/toksim/resource/agent/search",
    method: "post",
    data: params
  })
}

/** 根据id查询资源库信息 */
export function getAgentInfoApi(id: string) {
  return request<Agent.AgentViewInfoResponseData>({
    url: `/toksim/resource/agent/get/${id}`,
    method: "get"
  })
}
/** 获取智能体类型 */
export function getAgentTypeOptionsApi() {
  return request<ApiResponseData<string[]>>({
    url: `/toksim/resource/agent/type/get`,
    method: "get"
  })
}

/** 下载智能体资源 */
export function downloadAgentApi(id: string) {
  return request<AxiosResponse>({
    headers: {
      "Content-Type": "application/octet-stream"
    },
    responseType: "blob",
    url: `/toksim/resource/agent/download/${id}`,
    method: "get"
  })
}
